package reflect;

import reflect.annotations.AutoRunClass;

import java.io.File;
import java.net.URISyntaxException;

public class Test3 {
    public static void main(String[] args) throws Exception {
        File dir = new File(
                Test3.class.getResource(".").toURI()
        );

        File[] files = dir.listFiles(f->f.getName().contains(".class"));
        for (File file : files) {
            String name = file.getName();
            name = name.replace(".class","");
            Class cls = Class.forName(Test3.class.getPackage().getName()+"."+name);
            if (cls.isAnnotationPresent(AutoRunClass.class)) {
                Object obj = cls.newInstance();
                System.out.println(obj);
            }
        }
    }
}
